package io.zbc.grow.arithmetic.controller;

import io.zbc.grow.arithmetic.util.QuestionUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author zbc
 * @date 2022/12/1
 */
@RequestMapping("/question")
@Controller
public class QuestionController {

    @Autowired
    QuestionUtil questionUtil;

    @GetMapping("/mix/{maxValue}/{count}")
    public ModelAndView getMixQuestions(@PathVariable("maxValue") int maxValue, @PathVariable("count") int count) {
        return new ModelAndView("question/binary", "binaries", questionUtil.mixBinaries(maxValue, count));
    }

    @GetMapping("/{questionType}/{maxValue}/{count}")
    public ModelAndView getQuestions(@PathVariable("questionType") int questionType, @PathVariable("maxValue") int maxValue, @PathVariable("count") int count) {
        return new ModelAndView("question/binary", "binaries", questionUtil.binaries(questionType, maxValue, count));
    }

}
